import { combineReducers, AnyAction, ReducersMapObject, Reducer } from "redux";
import counter, { CounterState } from "./counter";
import router, { RouterState } from "./router";

export interface CombinedState {
  counter: CounterState;
  router: RouterState;
}
let reducers: ReducersMapObject<CombinedState, AnyAction> = {
  counter,
  router,
};
let reducer: Reducer<CombinedState> = combineReducers<CombinedState>(reducers);

export default reducer;

/* S = CombinedState;
keyof S = counter|router 


for (let K in counter|router){
   Reducer<CombinedState[counter],AnyAction>
   Reducer<CombinedState[router],AnyAction>
} */

/* let reducers={
  counter,
  router
};

type CombinedState = {
  [key in keyof typeof reducers]: ReturnType<typeof reducers[key]>
}

typeof reducers 
interface Reducers{
  counter:(state:CounterState,action:AnyAction)=>CounterState
  router:(state:RouterState,action:AnyAction)=>RouterState
}
keyof typeof reducers  counter|router

type CombinedState = {
 counter:CounterState
 router:RouterState
} */
